package org.redis.cluster.transport.netty.test;

import java.util.Objects;

import org.junit.Test;
import org.redis.cluster.config.ClientConfig;
import org.redis.cluster.redis.transport.codec.client.RedisClientProtocolDecoder;
import org.redis.cluster.redis.transport.codec.client.RedisClientProtocolEncoder;
import org.redis.cluster.transport.netty.client.NettyClient;

public class NettyClientTester_2 {

	@Test
	public void test() {
		ClientConfig clientConfig=new ClientConfig();
		clientConfig.setHost("127.0.0.1");
		clientConfig.setPort(6379);
		clientConfig.setTimeout(1000*3);
		clientConfig.setConnection(100);
		NettyClient client=new NettyClient(clientConfig, new RedisClientProtocolDecoder(), new RedisClientProtocolEncoder());
		
		while(true) {
			try {
				Thread.currentThread().sleep(1000);
				
				byte response[]=client.send("*1\r\n$4\r\nPING\r\n".getBytes());
				System.out.println(Objects.deepEquals("+PONG\r\n".getBytes(), response));
			}
			catch(Exception e) {
				e.printStackTrace();
			}
		}
	}
}